//
//  PaymentPriceTableViewCell.swift
//  LeTu
//
//  Created by gy on 2024/1/10.
//

import UIKit

class PaymentPriceTableViewCell: BaseTableViewCell {

    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        
        configUI()
    }
    static func getCellHeight() -> CGFloat {
        return 90
    }
    func setPriceModel(_ priceModel: VipPirceModel, isSelect: Bool) {
        
        selectIconImgView.image = UIImage(named: isSelect ? "price_check_box_select" : "price_check_box_unselect")
        nameLabel.text = LanguageManager.shared.currentLanguage == .zh ? priceModel.name:priceModel.englishName
        detailLabel.text = LanguageManager.shared.currentLanguage == .zh ? priceModel.subBrief:priceModel.subBriefEn
        priceLabel.attributed.text = "\("¥", .font(kSetPingFangBlod(11)))\(priceModel.productPrice)"
        
    }
    
    // MARK: - configUI
    func configUI() {
        
        backgroundColor = .white
        
        contentView.addSubview(backView)
        backView.addSubview(selectIconImgView)
        backView.addSubview(nameLabel)
        backView.addSubview(priceLabel)
        backView.addSubview(detailLabel)
        contentView.addSubview(lineView)
        
        backView.snp.makeConstraints { make in
            make.left.equalTo(24)
            make.right.equalTo(-24)
            make.centerY.equalToSuperview()
        }
        selectIconImgView.snp.makeConstraints { make in
            make.left.equalToSuperview()
            make.width.height.equalTo(14)
            make.top.equalToSuperview()
        }
        nameLabel.snp.makeConstraints { make in
            make.left.equalTo(selectIconImgView.snp.right).offset(14)
            make.height.equalTo(18)
            make.top.equalToSuperview()
        }
        priceLabel.snp.makeConstraints { make in
            make.right.centerY.equalToSuperview()
        }
        detailLabel.snp.makeConstraints { make in
            make.left.equalTo(nameLabel)
            make.top.equalTo(nameLabel.snp.bottom).offset(6)
            make.right.lessThanOrEqualTo(priceLabel.snp.left).offset(-12)
            make.bottom.equalToSuperview()
        }
        lineView.snp.makeConstraints { make in
            make.left.equalTo(20)
            make.right.equalTo(-20)
            make.bottom.equalToSuperview()
            make.height.equalTo(CGFloat.app_lineHieght)
        }
        
    }
    private lazy var backView: UIView = {
        let backView = UIView()
        return backView
    }()
    private lazy var selectIconImgView: UIImageView = {
        let selectIconImgView = UIImageView()
        selectIconImgView.image = UIImage(named: "price_check_box_unselect")
        return selectIconImgView
    }()
    private lazy var nameLabel: UILabel = {
        let nameLabel = UILabel()
        nameLabel.font = kSetPingFangBlod(16)
        return nameLabel
    }()
    private var detailLabel: UILabel = {
        let detailLabel = UILabel()
        detailLabel.font = kSetPingFangRegular(12)
        detailLabel.textColor = .app_textDarkGrayColor
        detailLabel.numberOfLines = 0
        return detailLabel
    }()
    private var priceLabel: UILabel = {
        let priceLabel = UILabel()
        priceLabel.font = kSetPingFangBlod(20)
        priceLabel.textColor = .app_priceTextColor
        priceLabel.textAlignment = .right
        return priceLabel
    }()
    private lazy var lineView: UIView = {
        let lineView = UIView()
        lineView.backgroundColor = .app_lineColor
        return lineView
    }()
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

}
